<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>长图转PDF工具</title>
    <script src="./jspdf.js"></script>
    <link rel="stylesheet" href="./index.css">
</head>
<body>
    <h1>长图转PDF工具</h1>
    <p class="subtitle">上传长图，自动分页为A4尺寸的PDF文件</p>
    
    <div class="container">
        <div class="upload-area" id="uploadArea">
            <div class="upload-icon">📄</div>
            <div class="upload-text">点击或拖拽图片到此处上传</div>
            <div class="upload-hint">支持 JPG、PNG 格式，最大 50MB</div>
            <input type="file" id="imageInput" accept="image/jpeg, image/png">
        </div>
        
        <div class="loading" id="loading">
            <div class="spinner"></div>
            <p>正在处理图片，请稍候...</p>
        </div>
        
        <div class="progress-text" id="progressText">处理进度: 0%</div>
        <div class="progress-bar" id="progressBar">
            <div class="progress-fill" id="progressFill"></div>
        </div>
        
        <div class="preview-section" id="previewSection">
            <h2 class="section-title">分页预览</h2>
            <div class="page-info" id="pageInfo"></div>
            
            <div class="option-group">
                <div class="option-title">布局选项</div>
                <div class="option-row">
                    <div class="option-item">
                        <input type="radio" id="fitWidth" name="layout" value="fitWidth" checked>
                        <label for="fitWidth">适应宽度（保持比例，推荐）</label>
                    </div>
                    <div class="option-item">
                        <input type="radio" id="fitHeight" name="layout" value="fitHeight">
                        <label for="fitHeight">适应高度（可能裁剪宽度）</label>
                    </div>
                </div>
                
                <div class="overlap-option">
                    <div class="option-item">
                        <input type="checkbox" id="enableOverlap" checked>
                        <label for="enableOverlap"><strong>重叠分页保护</strong> - 在页面间重复部分内容确保文字完整性</label>
                    </div>
                    <div class="overlap-slider">
                        <label>重叠高度：<span id="overlapValue">100</span> 像素</label>
                        <input type="range" id="overlapSlider" min="50" max="200" value="100" step="10">
                    </div>
                </div>
            </div>
            
            <div class="preview-container" id="previewContainer"></div>
            
            <div class="controls">
                <button class="btn btn-secondary" id="resetBtn">
                    <span>↺</span> 重新选择图片
                </button>
                <button class="btn btn-success" id="downloadBtn">
                    <span>⬇</span> 下载PDF文件
                </button>
            </div>
        </div>
    </div>

    <script src="./index.js"></script>
</body>
</html>